public class GreatestLetter {

    public String greatestLetter(String s) {
        char[] chars = s.toCharArray();
        int[] tempS = new int[26];
        int[] tempM = new int[26];
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] > 90) {
                tempS[chars[i] - 'a']++;
            } else {
                tempM[chars[i] - 'A']++;
            }
        }
        for (int i = 25; i >= 0; i--) {
            if (tempM[i] > 0 && tempS[i] > 0) {
                return  (char) ('A' + i) + "";
            }
        }
        return "";
    }
}
